# include<iostream>
# include<fstream>
using namespace std;


//Search Registration Number
int searchreg()
{
loop:
    int a=0;
	int n=0;
    
cout<<endl<<endl;
	cout<<"Enter the registration number of the student : ";  

	cin>>a;  // user enters Registration Number
	
	cout<<endl;

	//Following set of if_else statements assign student id an interger value which is part of a sequence(from 1 to 84)
	
	if(a==120)
	{	n=1;
	cout<<"Muddasir Ali Baig"<<endl<<endl;
	}

	else if(a==139)
	{	n=2;
	cout<<"Muhammad Zohaib Hayat"<<endl<<endl;
	}
	else if(a==235)
	{	n=3;
	cout<<"Abdul Moiz Kiani"<<endl<<endl;
	}
	else if(a==236)
	{	n=4;
	cout<<"Abdullah Baig"<<endl<<endl;
	}
	else if(a==239)
	{	n=5;
	cout<<"Ahmed Javed"<<endl<<endl;
	}
	else if(a==240)
	{	n=6;
	cout<<"Ahmed Shafqat"<<endl<<endl;
	}
	else if(a==241)
	{	n=7;
	cout<<"Ahmer Tajammul"<<endl<<endl;
	}
	else if(a==243)
	{	n=8;
	cout<<"Ali Raza"<<endl;
	}
	else if(a==245)
	{	n=9;
	cout<<"Anas Shoaib"<<endl;
	}
	else if(a==251)
	{	n=10;
	cout<<"Dillshad"<<endl;
	}
	else if(a==254)
	{	n=11;
	cout<<"Faiq Khalid"<<endl;
	}
	else if(a==259)
	{	n=12;
	cout<<"Hamza Tariq"<<endl;
	}
	else if(a==261)
	{	n=13;
	cout<<"Hassan Tahir"<<endl;
	}
	else if(a==263)
	{	n=14;
	cout<<"Inamullah Naveed"<<endl;
	}
	else if(a==266)
	{	n=15;
	cout<<"Jawwad Hassan"<<endl;
	}
	else if(a==267)
	{	n=16;
	cout<<"Khayyam Bahadur"<<endl;
	}
	else if(a==269)
	{	n=17;
	cout<<"Khurram Shahzad"<<endl;
	}
	else if(a==271)
	{	n=18;
	cout<<"Mahmood Ul Hassan"<<endl;
	}
	else if(a==274)
	{	n=19;
	cout<<"Muhammad Arslan Khalique"<<endl;
	}
	else if(a==275)
	{	n=20;
	cout<<"Muhammad Bilal Khan"<<endl;
	}
	else if(a==277)
	{	n=21;
	cout<<"Muhammad Fakhar Ali Khan"<<endl;
	}
	else if(a==280)
	{	n=22;
	cout<<"Muhammad Owais"<<endl;
	}
	else if(a==282)
	{	n=23;
	cout<<"Muhammad Tayyab Aslam"<<endl;
	}
	else if(a==284)
	{	n=24;
	cout<<"M. Uzair Zahid"<<endl;
	}
	else if(a==286)
	{	n=25;
	cout<<"Muhammad Yasin"<<endl;
	}
	else if(a==288)
	{	n=26;
	cout<<"Saad Abdullah"<<endl;
	}
	else if(a==289)
	{	n=27;
	cout<<"Saad Ali"<<endl;
	}
	else if(a==295)
	{	n=28;
	cout<<"Sheikh Mudaser Abdullah"<<endl;
	}
	else if(a==296)
	{	n=29;
	cout<<"Syed Farjad Zaheer"<<endl;
	}
	else if(a==299)
	{	n=30;
	cout<<"Syed Zeerak Ali"<<endl;
	}
	else if(a==306)
	{	n=31;
	cout<<"Waseem Anwar"<<endl;
	}
	else if(a==307)
	{	n=32;
	cout<<"Wasif Ali"<<endl;
	}
	else if(a==309)
	{	n=33;
	cout<<"Zain Pervaiz"<<endl;
	}
	else if(a==310)
	{	n=33;
	cout<<"Zaman Saleem"<<endl;
	}
	else if(a==311)
	{	n=35;
	cout<<"Ayesha Nasim"<<endl;
	}
	else if(a==313)
	{	n=36;
	cout<<"Hira Ali Jamal"<<endl;
	}
	else if(a==315)
	{	n=37;
	cout<<"Kinza Nasrullah"<<endl;
	}
	else if(a==318)
	{	n=38;
	cout<<"Nadra Ramzan"<<endl;
	}
	else if(a==319)
	{	n=39;
	cout<<"Naeha Sharif"<<endl;
	}
	else if(a==321)
	{	n=40;
	cout<<"Sahar Tanveer"<<endl;
	}
	else if(a==123)
	{	n=41;
	cout<<"Muhammad Ali Bajwa"<<endl;
	}
	else if(a==124)
	{	n=42;
	cout<<"Muhammad Atif Afzal"<<endl;
	}
	else if(a==136)
	{	n=43;
	cout<<"Muhammad Taimoor Shabbir"<<endl;
	}
	else if(a==159)
	{	n=44;
	cout<<"Usman Aziz"<<endl;
	}
	else if(a==234)
	{	n=45;
	cout<<"Abdul Aleem Ahsan"<<endl;
	}
	else if(a==237)
	{	n=46;
	cout<<"Abdullah Intekhab"<<endl;
	}
	else if(a==244)
	{	n=47;
	cout<<"Ali Raza"<<endl;
	}
	else if(a==246)
	{	n=48;
	cout<<"Armaghan Jamshaid"<<endl;
	}
	else if(a==248)
	{	n=49;
	cout<<"Bilal Ahmed"<<endl;
	}
	else if(a==249)
	{	n=50;
	cout<<"Bilal Zafar"<<endl;
	}
	else if(a==257)
	{	n=51;
	cout<<"Furqan Naseer"<<endl;
	}
	else if(a==268)
	{	n=52;
	cout<<"Khazal Dar"<<endl;
	}
	else if(a==270)
	{	n=53;
	cout<<"Muhammad Shoaib Akhtar"<<endl;
	}
	else if(a==273)
	{	n=54;
	cout<<"Muhammad Ali"<<endl;
	}
	else if(a==276)
	{	n=55;
	cout<<"Muhammad Bilal Khan"<<endl;
	}
	else if(a==279)
	{	n=56;
	cout<<"Muhammad Osama Sheri"<<endl;
	}
	else if(a==285)
	{	n=57;
	cout<<"Muhammad Waqas"<<endl;
	}
	else if(a==287)
	{	n=58;
	cout<<"Murtaza Manzoor"<<endl;
	}
	else if(a==290)
	{	n=59;
	cout<<"Saad Hussain"<<endl;
	}
	else if(a==292)
	{	n=60;
	cout<<"Sarmad Munir"<<endl;
	}
	else if(a==293)
	{	n=61;
	cout<<"Shehryar Tariq"<<endl;
	}
	else if(a==294)
	{	n=62;
	cout<<"Sheikh Arslan Ali Riaz"<<endl;
	}
	else if(a==297)
	{	n=63;
	cout<<"Syed Kamran Haider"<<endl;
	}
	else if(a==298)
	{	n=64;
	cout<<"Syed Nasar Shahzad"<<endl;
	}
	else if(a==302)
	{	n=65;
	cout<<"Usman Asghar"<<endl;
	}
	else if(a==303)
	{	n=66;
	cout<<"Usman Moin"<<endl;
	}
	else if(a==304)
	{	n=67;
	cout<<"Waqas Gul"<<endl;
	}
	else if(a==305)
	{	n=68;
	cout<<"Waqas Saeed Butt"<<endl;
	}
	else if(a==312)
	{	n=69;
	cout<<"Azka Zafar Rana"<<endl;
	}
	else if(a==314)
	{	n=70;
	cout<<"Javeria Mughal"<<endl;
	}
	else if(a==316)
	{	n=71;
	cout<<"Mahwish Zahra"<<endl;
	}
	else if(a==317)
	{	n=72;
	cout<<"Maryam Awan"<<endl;
	}
	else if(a==320)
	{	n=73;
	cout<<"Sadia Anwar"<<endl;
	}
	else if(a==322)
	{	n=74;
	cout<<"Sehrish Khan"<<endl;
	}
	else
	{
		cout<<"Wrong Entry !!!"<<endl;  // if Wrong student id is inserted
		goto loop;
	}
	return n;
}



// Quiz Marks
void showquiz(int n,float x[][11])
{
	cout<<"Numbers in quizzes are : ";
	for(int i=0;i<3;i++)
	cout<<x[n-1][i]<<"  ";
	cout<<endl<<endl;
}


// Quiz Average
void avequiz(int n,float x[][11])
{
	float aq=0;
	for(int i=0;i<3;i++)
	{
		aq=aq+x[n-1][i];
	}
	cout<<"Average in quizzes is : ";
	cout<<aq/3;
	cout<<endl<<endl;
}

// Assignment Marks
void showhomeas(int n,float x[][11])
{
	cout<<"Numbers in home assignments are : ";
	for(int i=3;i<6;i++)
	cout<<x[n-1][i]<<"  ";
	cout<<endl<<endl;
}



//Assignment Average
void avehomeas(int n,float x[][11])
{
	float aha=0;
	float ha[3]={0,0,0};
	ha[1]=x[n-1][3];
	ha[2]=x[n-1][4];
	ha[3]=x[n-1][5];

	aha=(x[n-1][3]/10+x[n-1][4]/10+x[n-1][5]/15)*5;
	
	cout<<"Average in assignments is : ";
	cout<<aha;
	cout<<endl<<endl;

}



// milestone Marks
void showmil(int n,float x[][11])
{
	cout<<"Marks in project milestones are : ";
	for(int i=6;i<9;i++)
	cout<<x[n-1][i]<<"  ";
	cout<<endl<<endl;
}

// milestone Average
void avemil(int n,float x[][11])
{
	float apms=0;
	float pms[3]={0,0,0};
	pms[1]=x[n-1][6];
	pms[2]=x[n-1][7];
	pms[3]=x[n-1][8];

	apms=((pms[1]*10)+(pms[2]*25)+(pms[3]*30))/65;

	cout<<"Average in project milestones are : "<<apms<<endl;

}


// OHTs Marks
void showoht(int n,float x[][11])
{
	cout<<"Marks in OHTs are : ";
	for(int i=9;i<11;i++)
	cout<<x[n-1][i]<<"  ";
	cout<<endl<<endl;
}

// Average OHT Marks
void aveoht(int n,float x[][11])
{
	float aoht=0;
	float oht[2]={0,0};
	oht[1]=x[n-1][9];
	oht[2]=x[n-1][10];

	aoht=((oht[1])+(oht[2]/4));

	cout<<"Average in OHTs are : "<<aoht<<endl;
}



// Net Weightage of a Student
float netweightage(int n,float x[][11])
{

	float aq=0;
	float aha=0;
	float apms=0;
    float aoht=0;
    float nw=0;


	aq=(x[n-1][0]+x[n-1][1]+x[n-1][2])/3;
	aha=(x[n-1][3]/10+x[n-1][4]/10+x[n-1][5]/15)*10/3;
	apms=((x[n-1][6]*10)+(x[n-1][7]*25)+(x[n-1][8]*30))/65;
	aoht=((x[n-1][9])+(x[n-1][10]/4));

	
	nw=aq+aha+apms+aoht;
	
	cout<<endl;
	return nw;
}


// Class Average
float classaverage(int n,float x[][11])
{

    float aq=0;
	float aha=0;
	float apms=0;
    float aoht=0;
    float nw=0;

	aq=(x[n-1][0]+x[n-1][1]+x[n-1][2])/3;
	aha=(x[n-1][3]/10+x[n-1][4]/10+x[n-1][5]/15)*10/3;
	apms=((x[n-1][6]*10)+(x[n-1][7]*25)+(x[n-1][8]*30))/65;
	aoht=((x[n-1][9])+(x[n-1][10]/4));

	nw=aq+aha+apms+aoht;
		
	return (nw);
	

}










int main()
{
 float x[74][11];   // A 2 Dimensional Array is initialized

	ifstream s("The file.txt");     

	for(int i=0;i<74;i++)     // Data is Stored to 2 Dimensional array from the text file "The file.txt"
	{                     
		for(int j=0;j<11;j++)
			s>>x[i][j];   // Extracting Data from file to array
	}


	
	int a=0;
	int n=0;
	float y=0;
	float classave=0;
	int choice=0;


aga:

// Menu
	cout<<endl<<"Welcome"<<endl<<endl;

	cout<<"MENU"<<endl<<endl;

        cout<<"Press 1 for Teacher's Menu"<<endl;
        
        cout<<"Press 2 for Student's Menu"<<endl;

        cout<<"Press 0 for Exit"<<endl;

	   cout<<endl<<endl;
 
        cin>>choice;            //Integer value is inserted in order to perform desired function
	cout<<endl<<endl;


switch(choice)
	{
	case 2:
		{

again:

	// Student Interface
        cout<<endl<<endl;
		
			n=searchreg();
moin:
    cout<<endl<<endl;
	cout<<" 1. Display marks in quizzes"<<endl;
	cout<<" 2. Display marks in assignments"<<endl;
	cout<<" 3. Display marks in ohts"<<endl;
	cout<<" 4. Display marks in project milestones"<<endl;
	cout<<" 5. Display average in quizzes"<<endl;
	cout<<" 6. Display average in assignments"<<endl;
	cout<<" 7. Display average in ohts"<<endl;
	cout<<" 8. Display average in project milestones"<<endl;
	cout<<" 9. Display net weightage out of "<<endl;
	cout<<"10. Display class average out of "<<endl;
	cout<<"11. Display all data student"<<endl;
    cout<<"12. Evaluate student performance"<<endl;
    cout<<"13. Get data of some other student"<<endl;
	cout<<" 0. EXIT"<<endl<<endl;
	
	cout<<"Enter your choice : ";
	cin>>a;            //Integer value is inserted in order to perform desired function
	cout<<endl;
	switch(a)
	{
	case 1:
		showquiz(n,x);    // Displays marks of Quizzes a particular student
		break;

	case 2:
		showhomeas(n,x);  // Displays Home Assignments marks of a  particular student
		break;

	case 3:
		showoht(n,x);   // Displays OHTs marks of a particular student
		break;

	case 4:
		showmil(n,x);      // Displays Mid Term marks of a particular student
		break;

	case 5:
		avequiz(n,x);      // Displays average quiz marks of a particular student
		break;

	case 6:
		avehomeas(n,x);     // Displays average home assignment marks of a particular student
		break;

	case 7:
		aveoht(n,x);      // Displays average lab assignment marks of a particular student
		break; 

	case 8:
		avemil(n,x);        // Displays weighed mid term marks of a particular student
		break;

	case 9:
		cout<<"Net weightage is  : "<<netweightage(n,x)<<endl; // Displays Net Weightage of a particular student
		break;

	case 10:
		for(int i=1;i<74;i++)  // Displays Class Average
	{
		y=y+classaverage(i,x);
	}

	classave=y/74;

	cout<<"The class average is : "<<classave<<endl;

		break;

	case 11:   // Displays all the Data of a particular Student
		showquiz(n,x);
        showhomeas(n,x);
		showmil(n,x);
		showoht(n,x);
		avequiz(n,x);
		avehomeas(n,x);
        avemil(n,x);
        aveoht(n,x);
		cout<<"Net weightage is  : "<<netweightage(n,x)<<endl<<endl;
        
		break;


	case 12: // Grades Performance on basis of Net Weightage
		// Student with Netweightage equal and above 40% is graded Excellent
		// Student with Netweightage b/w 30% & 40% is graded Good
        // Student with Netweightage b/w 20% & 30% is graded Satisfactory
		// Student with Netweightage less than 20% is graded Poor

		if (netweightage(n,x)>=55)                                      
			cout<<"Student performance is Excellent!"<<endl;
      
        if ((netweightage(n,x)>=45)&&(netweightage(n,x)<55))
			cout<<"Student performance is GOOD!"<<endl;

        if ((netweightage(n,x)>=35)&&(netweightage(n,x)<45))
			cout<<"Student performance is Satisfactory"<<endl;

        if (netweightage(n,x)<35)
			cout<<"Student performance is Poor"<<endl;

      	break;
	
	
	
	case 13:   // Goes to start in order to view details of other student
		goto again; 
		break;



	
	case 0:  // Exits
		cout<<"Thankyou......"<<endl;
		return 0;

	}
	goto moin;
	}
	

	case 1:
		{
		 // Teacher Interface

	int b,i=0;
	char choice[]="****";
	char a[]="0000";

waqas:
	
	cout<<"Enter Password : ";
	cin>>a;            //Integer value is inserted in order to perform desired function
	cout<<endl;


if ((choice[0]==a[0])&&(choice[1]==a[1])&&(choice[2]==a[2])&&(choice[3]==a[3]))
		b=1;
else
        b=0;
		
switch(b)
	{
	case 1:
	{
			cout<<"Password Accepted"<<endl<<endl;
			goto again;
		break;
	}

	case 0:
	{
		cout<<"Password Invalid"<<endl<<endl;
		cout<<"Press 1 to re-enter password"<<endl;
		cout<<"Press 0 to go to main menu"<<endl;
		cin>>i;
		if(i==1)
				goto waqas;
		if(i==0)
			    goto aga;
		break;
	}

}

		break;
		}
   	
	case 0:
		 // Exits
		cout<<"Thankyou......"<<endl;
		return 0;
}
goto aga;
}
		




		

	
